<?php
  include_once 'global.php';
  if($logined==false){
  	echo "<script>alert('请先登录');location.href='login.php';</script>";
  }
  else{
  $smarty->display('editinfo.html');
  //if($_POST['user_nick']) echo "user_nickname";
  if($_POST['user_sex']&&$_POST['user_age']&&$_POST['user_birth']&&$_POST['user_address']&&$_POST['user_email']&&$_POST['user_info']&&$_POST['user_nick']&&$_POST['blog_name']){
  	$user_age=intval($_POST['user_age']);
  	$user_nickname=htmlspecialchars($_POST['user_nick']);
  	$user_birth=htmlspecialchars($_POST['user_birth']);
  	$user_address=htmlspecialchars($_POST['user_address']);
  	$user_email=htmlspecialchars($_POST['user_email']);
  	$user_info=htmlspecialchars($_POST['user_info']);
	$blog_name=htmlspecialchars($_POST['blog_name']);
  	//echo "aaa!";
  	$sql="UPDATE `user` SET  `user_sex` =  '$_POST[user_sex]',
  	`user_nickname` =  '$user_nickname',
    `user_age` =  '$user_age',
    `user_birth` =  '$user_birth',
    `user_address` =  '$user_address',
    `user_email` =  '$user_email',
	`blog_name`='$blog_name',
    `user_info` =  '$user_info' WHERE `user_name`='admin';";
  	if($db->query($sql)){
  		echo "<script>alert('编辑个人资料成功');location.href='userinfo.php';</script>";
  	}
  }
  }
?>